﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Dapper.Extensions.Test;
using Dapper.Model;

namespace UnitTest
{
    [TestClass]
    public class UnitTest2
    {
        [TestMethod]
        public void TestGet()
        {
            SqlServerRepository repo = SqlServerRepository.Instance;
            var entity = repo.Get<Patient>(new {ID = 2 });
            Assert.AreEqual(entity.Name, "张旭");
        }

        [TestMethod]
        public void TestInsert()
        {
            SqlServerRepository repo = SqlServerRepository.Instance;
            var id = repo.Insert<Patient>(new Patient
            {
                Name = "Star",
                Sex = 2,
                Status = 1
            });
            Assert.AreNotEqual(id, 0);
        }

        [TestMethod]
        public void TestDelete()
        {
            SqlServerRepository repo = SqlServerRepository.Instance;
            var isSucceed = repo.Delete<Patient>(new { ID = 16 });
            Assert.AreEqual(isSucceed, true);
        }

        [TestMethod]
        public void TestUpdate()
        {
            SqlServerRepository repo = SqlServerRepository.Instance;
            var isSucceed = repo.Update<Patient>(new Patient
            {
                Name = "Rose",
                ID =15,
                Sex = 2,
                Status = 0
            });
            Assert.AreEqual(isSucceed, true);
        }
    }
}
